<?php

include("mysql_conn.php");

$projectid = mysql_real_escape_string($_POST["projectid"]);
$updatetype = mysql_real_escape_string($_POST["updatetype"]);
$updatetext =  mysql_real_escape_string($_POST["updatetext"]);
$updatedate =  mysql_real_escape_string($_POST["updatedate"]);

if ($updatetype == 'T' || $updatetype == 'O' || $updatetype == 'N')
{
$sql="insert into updates (projectid, updatetype, updatetext, updatedate)
values
('$projectid','$updatetype','$updatetext', str_to_date('$updatedate','%m/%d/%Y'))";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "<html><head><meta http-equiv='refresh' content='0;url=editproj.php?projectid=$_POST[projectid]'><link rel='stylesheet' type='text/css' href='style.css'></head><body>
Update Added successfully.<p>
<a href='editproj.php?projectid=$_POST[projectid]'>Back</a>
</body></html>";
}
else
{
echo "<html><head></head><body>
Please remember to select an update type<p>
Go back to preserve your data or click <a href='editproj.php?projectid=$_POST[projectid]'>here</a> to go back and lose it. 
</body></html>";
}

mysql_close($con)
?>
